import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '关联合同',
    align:"center",
    dataIndex: 'contractId'
   },
   {
    title: '合同编号',
    align:"center",
    dataIndex: 'contractNumber'
   },
   {
    title: '合同主题',
    align:"center",
    dataIndex: 'contractTheme'
   },
   {
    title: '项目名字',
    align:"center",
    dataIndex: 'projectName'
   },
   {
    title: '项目内容',
    align:"center",
    dataIndex: 'projectContent'
   },
   {
    title: '合同金额',
    align:"center",
    dataIndex: 'contractAmount',
    customRender: ({ text }) => {
      if (text === null || text === undefined || text === '') {
        return '-';
      }
      return text.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
    }
   },
   {
    title: '剩余金额',
    align:"center",
    dataIndex: 'remainedAmount',
    customRender: ({ text }) => {
      if (text === null || text === undefined || text === '') {
        return '-';
      }
      return text.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
    }
   },
   {
    title: '创建时间',
    align:"center",
    dataIndex: 'createdAt'
   },
];

//子表表格配置
export const subProjectsColumns: JVxeColumn[] = [
    {
      title: '关联项目',
      key: 'projectId',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
      disabled: true, // 只读
    },
    {
      title: '关联项目名称',
      key: 'taskName',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '子项目名称',
      key: 'subProjectName',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '子项目内容',
      key: 'subProjectContent',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '子项目金额',
      key: 'subProjectAmount',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue: 0,
      precision: 2, // 保留两位小数
    },
    {
      title: '创建时间',
      key: 'createAt',
      type: JVxeTypes.datetime,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
      disabled: true, // 只读
    }
  ]

// 高级查询数据
export const superQuerySchema = {
  contractId: {title: '关联合同',order: 0,view: 'text', type: 'string',},
  contractNumber: {title: '合同编号',order: 1,view: 'text', type: 'string',},
  contractTheme: {title: '合同主题',order: 2,view: 'text', type: 'string',},
  projectName: {title: '项目名字',order: 3,view: 'text', type: 'string',},
  projectContent: {title: '项目内容',order: 4,view: 'text', type: 'string',},
  contractAmount: {title: '合同金额',order: 5,view: 'text', type: 'string',},
  remainedAmount: {title: '剩余金额',order: 6,view: 'text', type: 'string',},
  createdAt: {title: '创建时间',order: 7,view: 'text', type: 'string',},
  //子表高级查询
  subProjects: {
    title: '子项目表',
    view: 'table',
    fields: {
        projectId: {title: '关联项目',order: 0,view: 'text', type: 'string',},
        taskName: {title: '关联项目名称',order: 1,view: 'text', type: 'string',},
        subProjectName: {title: '子项目名称',order: 2,view: 'text', type: 'string',},
        subProjectContent: {title: '子项目内容',order: 3,view: 'text', type: 'string',},
        subProjectAmount: {title: '子项目金额',order: 4,view: 'text', type: 'string',},
        createAt: {title: '创建时间',order: 5,view: 'datetime', type: 'string',},
    }
  },
};
